import {
	baseUrl
} from './config.js'
export function topList() {
	return new Promise(function(resolve, reject) {
		uni.request({
			url: `${baseUrl}/toplist/detail`,
			method: 'GET',
			data: {},
			success(res) {
				let result = res.data.list
				result.length = 4
				resolve(result)
			}
		})
	})

}

export function list(listid) {
	return new Promise(function(resolve, reject) {
		uni.request({
			url: `${baseUrl}/playlist/detail?id=${listid}`,
			method: 'get',
			data: {},
			success(res) {
				resolve(res)
			}

		})
	})
}

export function songDetail(songId) {
	return new Promise(function(resolve, reject) {
		uni.request({
			url: `${baseUrl}/song/detail?ids=${songId}`,
			method: 'get',
			data: {},
			success(res) {
				resolve(res)
			}
		})
	})
}

export function songSimi(songId) {
	return new Promise(function(resolve, reject) {
		uni.request({
			url: `${baseUrl}/simi/song?id=${songId}`,
			method: 'get',
			data: {},
			success(res) {
				resolve(res)
			}
		})
	})
}

export function songComment(songId) {
	return new Promise(function(resolve, reject) {
		uni.request({
			url: `${baseUrl}/comment/music?id=${songId}`,
			method: 'get',
			data: {},
			success(res) {
				resolve(res)
			}
		})
	})
}

export function songLyric(songId) {
	return new Promise(function(resolve, reject) {
		uni.request({
			url: `${baseUrl}/lyric?id=${songId}`,
			method: 'get',
			data: {},
			success(res) {
				resolve(res)
			}
		})
	})
}

export function songUrl(songId) {
	return new Promise(function(resolve, reject) {
		uni.request({
			url: `${baseUrl}/song/url?id=${songId}`,
			method: 'get',
			data: {},
			success(res) {
				resolve(res)
			}
		})
	})
}

export function searchHot() {
	return new Promise(function(resolve, reject) {
		uni.request({
			url: `${baseUrl}/search/hot/detail`,
			method: 'get',
			data: {},
			success(res) {
				resolve(res)
			}
		})
	})
}

export function searchWord(word) {
	return new Promise(function(resolve, reject) {
		uni.request({
			url: `${baseUrl}/search?keywords=${word}`,
			method: 'get',
			data: {},
			success(res) {
				resolve(res)
			}
		})
	})
}

export function searchSuggest(word) {
	return new Promise(function(resolve, reject) {
		uni.request({
			url: `${baseUrl}/search/suggest?keywords=${word}&type=mobile`,
			method: 'get',
			data: {},
			success(res) {
				resolve(res)
			}
		})
	})
}
